package com.kcwl.carrier.application.assembler;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.kcwl.carrier.domain.entity.CarrierCompanyInfo;
import com.kcwl.carrier.domain.entity.CarrierCooperateInfo;
import com.kcwl.carrier.domain.entity.CarrierInfo;
import com.kcwl.carrier.domain.entity.VehicleInfo;
import com.kcwl.carrier.infrastructure.constant.CarrierConstant;
import com.kcwl.carrier.infrastructure.enums.CarrierAuthStatusEnum;
import com.kcwl.carrier.infrastructure.enums.CarrierUseErrorCodeEnum;
import com.kcwl.carrier.infrastructure.exceptions.CarrierUserException;
import com.kcwl.carrier.infrastructure.utils.DateUtil;
import com.kcwl.carrier.interfaces.command.CarrierAuditCommand;
import com.kcwl.carrier.interfaces.command.CarrierInfoCommand;
import com.kcwl.carrier.interfaces.command.CompanyAuditCommand;
import com.kcwl.carrier.interfaces.dto.CarrierApproveInfoDTO;
import com.kcwl.carrier.interfaces.dto.CarrierCenterInfoDTO;
import com.kcwl.ddd.application.constants.IdentityTypeEnum;
import com.kcwl.euc.interfaces.dto.UserInfoDTO;
import com.kcwl.framework.utils.CollectionUtil;
import com.kcwl.framework.utils.KcBeanConverter;
import com.kcwl.framework.utils.StringUtil;

import java.util.*;

/**
 * @author 刘旭超
 * @date 2022年06月13日 10:21
 * @Description 用于用户基础信息接口层和领域层的数据转换
 */
public class CarrierInfoAssembler {

    /**
     * 封装司机用户认证信息
     */
    public static CarrierApproveInfoDTO createCarrierApproveInfo(UserInfoDTO userBaseInfo, CarrierInfo carrierInfo, CarrierCompanyInfo carrierCompanyInfo, CarrierCooperateInfo carrierCooperateInfo, Map<Long, String> rejectMap) {
        CarrierApproveInfoDTO approveInfoDTO = new CarrierApproveInfoDTO();
        // 用户信息
        approveInfoDTO.setRealName(userBaseInfo.getRealName());
        approveInfoDTO.setMobile(userBaseInfo.getMobile());
        approveInfoDTO.setIdCardNo(userBaseInfo.getIdCardNo());
        approveInfoDTO.setIdCardFront(userBaseInfo.getIdCardFront());
        approveInfoDTO.setIdCardBehind(userBaseInfo.getIdCardBehind());
        approveInfoDTO.setIdCardAddress(userBaseInfo.getIdCardAddress());
        approveInfoDTO.setUserAuthStatus(userBaseInfo.getAuthStatus());
        approveInfoDTO.setUserRemark(userBaseInfo.getAuthMsg());
        approveInfoDTO.setProvinceCode(userBaseInfo.getIdCardProvinceCode() == null ? null : userBaseInfo.getIdCardProvinceCode().toString());
        approveInfoDTO.setProvinceName(userBaseInfo.getIdCardProvinceName());
        approveInfoDTO.setCityCode(userBaseInfo.getIdCardCityCode() == null ? null : userBaseInfo.getIdCardProvinceCode().toString());
        approveInfoDTO.setCityName(userBaseInfo.getIdCardCityName());
        approveInfoDTO.setAreaCode(userBaseInfo.getIdCardCountyCode() == null ? null : userBaseInfo.getIdCardCountyCode().toString());
        approveInfoDTO.setAreaName(userBaseInfo.getIdCardCountyName());

        // 司机信息
        approveInfoDTO.setDrivingLicencePic(carrierInfo.getDrivingLicencePic());
        approveInfoDTO.setAllowDrivingModel(carrierInfo.getAllowDrivingModel());
        approveInfoDTO.setDriverQualificationPic(carrierInfo.getDriverQualificationPic());
        approveInfoDTO.setDriverLicenseEndTime(carrierInfo.getDriverLicenseEndTime());
        approveInfoDTO.setDrivingLicenceNo(carrierInfo.getDrivingLicenceNo());
        approveInfoDTO.setCarrierAuthStatus(carrierInfo.getAuthenticationStatus());
        approveInfoDTO.setRejectReason(carrierInfo.getRejectReason());
        approveInfoDTO.setCarrierRemark(carrierInfo.getAuthenticationRemark());
        approveInfoDTO.setRejectReasonList(rejectReasonConverter(rejectMap, carrierInfo.getRejectReason()));

        if (carrierCompanyInfo != null) {
            approveInfoDTO.setBusinessLicencePic(carrierCompanyInfo.getBusinessLicencePic());
            approveInfoDTO.setBusinessLicenceEndTime(carrierCompanyInfo.getBusinessLicenceEndTime());
            approveInfoDTO.setRoadPermitPic(carrierCompanyInfo.getRoadPermitPic());
            approveInfoDTO.setEnterpriseName(carrierCompanyInfo.getEnterpriseName());
            approveInfoDTO.setLegalName(carrierCompanyInfo.getLegalName());
            approveInfoDTO.setLegalIdCardNo(carrierCompanyInfo.getLegalIdCardNo());
            approveInfoDTO.setUnifiedSocialCreditCode(carrierCompanyInfo.getUnifiedSocialCreditCode());
            approveInfoDTO.setAddress(carrierCompanyInfo.getAddress());
            approveInfoDTO.setBankCardNo(carrierCompanyInfo.getBankCardNo());
            approveInfoDTO.setBankCardName(carrierCompanyInfo.getBankCardName());
            approveInfoDTO.setBankAccounts(carrierCompanyInfo.getBankAccounts());
            approveInfoDTO.setBankProvinceCode(carrierCompanyInfo.getBankProvinceCode());
            approveInfoDTO.setBankProvinceName(carrierCompanyInfo.getBankProvinceName());
            approveInfoDTO.setBankCityCode(carrierCompanyInfo.getBankCityCode());
            approveInfoDTO.setBankCityName(carrierCompanyInfo.getBankCityName());
            approveInfoDTO.setBankCountyCode(carrierCompanyInfo.getBankCountyCode());
            approveInfoDTO.setBankCountyName(carrierCompanyInfo.getBankCountyName());
            approveInfoDTO.setBankBranchAccounts(carrierCompanyInfo.getBankBranchAccounts());
            approveInfoDTO.setCompanyProvinceCode(carrierCompanyInfo.getProvinceCode());
            approveInfoDTO.setCompanyProvinceName(carrierCompanyInfo.getProvinceName());
            approveInfoDTO.setCompanyCityCode(carrierCompanyInfo.getCityCode());
            approveInfoDTO.setCompanyCityName(carrierCompanyInfo.getCityName());
            approveInfoDTO.setCompanyCountyCode(carrierCompanyInfo.getCountyCode());
            approveInfoDTO.setCompanyCountyName(carrierCompanyInfo.getCountyName());
            approveInfoDTO.setCompanyAddress(carrierCompanyInfo.getAddress());
            approveInfoDTO.setIndustry(carrierCompanyInfo.getIndustry());
            approveInfoDTO.setIncorporationDate(carrierCompanyInfo.getIncorporationDate());
            approveInfoDTO.setRegisteredCapital(carrierCompanyInfo.getRegisteredCapital());
            approveInfoDTO.setCompanyWebsite(carrierCompanyInfo.getCompanyWebsite());
        }

        if (carrierCooperateInfo != null) {
            approveInfoDTO.setCooperateEnterpriseName(carrierCooperateInfo.getEnterpriseName());
            approveInfoDTO.setCooperateUnifiedSocialCreditCode(carrierCooperateInfo.getUnifiedSocialCreditCode());
            approveInfoDTO.setCooperateType(carrierCooperateInfo.getCooperateType());
            approveInfoDTO.setCooperateProvePic(carrierCooperateInfo.getCooperateProvePic());
        }

        return approveInfoDTO;
    }

    /**
     * 封装司机用户信息
     */
    public static CarrierCenterInfoDTO createCarrierCenterInfo(UserInfoDTO userBaseInfo, CarrierInfo carrierInfo, CarrierCompanyInfo carrierCompanyInfo, List<VehicleInfo> vehicleInfoList) {
        CarrierCenterInfoDTO carrierCenterInfo = new CarrierCenterInfoDTO();
        carrierCenterInfo.setUserId(userBaseInfo.getId());
        carrierCenterInfo.setMobile(userBaseInfo.getMobile());
        carrierCenterInfo.setAvatar(userBaseInfo.getAvatar());

        carrierCenterInfo.setIdentityType(converterIdentity(userBaseInfo.getIdentityTypeList()));
        if (carrierInfo != null) {
            carrierCenterInfo.setAuthStatus(carrierInfo.getAuthenticationStatus());
            carrierCenterInfo.setAppraisalScore(carrierInfo.getAppraisalScore());
            carrierCenterInfo.setAllowDrivingModel(carrierInfo.getAllowDrivingModel());
        } else {
            carrierCenterInfo.setAuthStatus(CarrierAuthStatusEnum.UNCOMMITTED.getCode());
            carrierCenterInfo.setAppraisalScore(0);
        }
        carrierCenterInfo.setName(getCarrierNickname(userBaseInfo, carrierInfo, carrierCompanyInfo));
        // 车辆状态
        if (CollectionUtil.isEmpty(vehicleInfoList)) {
            carrierCenterInfo.setVehicleAuthStatus(0);
        } else if (vehicleInfoList.size() == 1) {
            carrierCenterInfo.setVehicleAuthStatus(vehicleInfoList.get(0).getAuthenticationStatus());
        } else {
            Long reject = vehicleInfoList.stream().filter(vehicleInfo -> vehicleInfo.getAuthenticationStatus() == 3).count();
            Long wait = vehicleInfoList.stream().filter(vehicleInfo -> vehicleInfo.getAuthenticationStatus() == 1).count();
            Long pass = vehicleInfoList.stream().filter(vehicleInfo -> vehicleInfo.getAuthenticationStatus() == 2).count();
            if (reject > 0) {
                carrierCenterInfo.setVehicleAuthStatus(3);
            } else if (wait > 0) {
                carrierCenterInfo.setVehicleAuthStatus(1);
            } else if (pass.longValue() == vehicleInfoList.size()) {
                carrierCenterInfo.setVehicleAuthStatus(2);
            }
        }
        if (userBaseInfo.getIdCardEndTime() != null) {
            Date now = DateUtil.getDate(DateUtil.formatDate(new Date(), "yyyy-MM-dd"));
            carrierCenterInfo.setIdCardExpiredStatus(now.after(userBaseInfo.getIdCardEndTime()) ? 1 : 0);
        }
        return carrierCenterInfo;
    }

    /**
     * 获取司机昵称
     */
    public static String getCarrierNickname(UserInfoDTO userBaseInfo, CarrierInfo carrierInfo, CarrierCompanyInfo carrierCompanyInfo) {
        String nickname;
        // 用户昵称处理
        if (carrierInfo != null) {
            if (CarrierAuthStatusEnum.PASS.getCode() == carrierInfo.getAuthenticationStatus()) {
                if (IdentityTypeEnum.CARRIER_TCOM_MANAGER.getSubType().equals(carrierInfo.getIdentityType())) {
                    nickname = carrierCompanyInfo.getEnterpriseName();
                } else {
                    nickname = userBaseInfo.getRealName();
                }
            } else {
                nickname = CarrierConstant.DRIVER_DEFAULT_NICKNAME;
            }
        } else {
            nickname = CarrierConstant.DRIVER_DEFAULT_NICKNAME;
        }
        return nickname;
    }

    /**
     * 构造运力辅助人审核信息
     * @param cooperateInfo
     * @param carrierAuditCommand
     * @return
     */
    public static CarrierCooperateInfo buildCooperateInfo(CarrierCooperateInfo cooperateInfo, CarrierAuditCommand carrierAuditCommand) {
        if (!StringUtil.isEmpty(carrierAuditCommand.getCooperateEnterpriseName())) {
            cooperateInfo.setEnterpriseName(carrierAuditCommand.getCooperateEnterpriseName());
        }
        if (!StringUtil.isEmpty(carrierAuditCommand.getCooperateType())) {
            cooperateInfo.setCooperateType(carrierAuditCommand.getCooperateType());
        }
        if (!StringUtil.isEmpty(carrierAuditCommand.getCooperateProvePic())) {
            cooperateInfo.setCooperateProvePic(carrierAuditCommand.getCooperateProvePic());
        }
        return cooperateInfo;
    }

    /**
     * 构造物流公司审核信息
     * @param carrierCompanyInfo
     * @param companyAuditCommand
     * @param identityType
     * @return
     */
    public static CarrierCompanyInfo buildCompanyInfo(CarrierCompanyInfo carrierCompanyInfo, CompanyAuditCommand companyAuditCommand, Integer identityType) {
        carrierCompanyInfo.setEnterpriseName(companyAuditCommand.getEnterpriseName());
        carrierCompanyInfo.setIndustry(companyAuditCommand.getIndustry());
        carrierCompanyInfo.setIncorporationDate(companyAuditCommand.getIncorporationDate());
        carrierCompanyInfo.setRegisteredCapital(companyAuditCommand.getRegisteredCapital());
        carrierCompanyInfo.setCompanyWebsite(companyAuditCommand.getCompanyWebsite());
        carrierCompanyInfo.setUnifiedSocialCreditCode(companyAuditCommand.getUnifiedSocialCreditCode());
        carrierCompanyInfo.setAddress(companyAuditCommand.getAddress());
        carrierCompanyInfo.setBusinessLicencePic(companyAuditCommand.getBusinessLicencePic());
        carrierCompanyInfo.setBusinessLicenceEndTime(companyAuditCommand.getBusinessLicenceEndTime());
        if (IdentityTypeEnum.CARRIER_TCOM_MANAGER.getSubType().equals(identityType)) {
            carrierCompanyInfo.setRoadPermitPic(companyAuditCommand.getRoadPermitPic());
        }
        return carrierCompanyInfo;
    }

    /**
     * 身份类型转换
     * @param identityTypeList
     * @return
     */
    public static Integer converterIdentity(List<Integer> identityTypeList) {
        if (identityTypeList.contains(IdentityTypeEnum.CARRIER_DRIVER.getType())) {
            return IdentityTypeEnum.CARRIER_DRIVER.getSubType();
        } else if (identityTypeList.contains(IdentityTypeEnum.CARRIER_SFLTOP.getType())) {
            return IdentityTypeEnum.CARRIER_SFLTOP.getSubType();
        } else if (identityTypeList.contains(IdentityTypeEnum.CARRIER_BRKR.getType())) {
            return IdentityTypeEnum.CARRIER_BRKR.getSubType();
        } else if (identityTypeList.contains(IdentityTypeEnum.CARRIER_TCOM_MANAGER.getType())) {
            return IdentityTypeEnum.CARRIER_TCOM_MANAGER.getSubType();
        } else if (identityTypeList.contains(IdentityTypeEnum.CARRIER_TDSPR.getType())) {
            return IdentityTypeEnum.CARRIER_TDSPR.getSubType();
        }
        throw new CarrierUserException(CarrierUseErrorCodeEnum.ILLEGAL_IDENTITY);
    }

    /**
     * 运力审核转换(字段名称不一致)
     * 司机
     * @param carrierAuditCommand
     * @return
     */
    public static CarrierInfo converterAuditCarrierInfo(CarrierAuditCommand carrierAuditCommand) {
        CarrierInfo bean = KcBeanConverter.toBean(carrierAuditCommand, CarrierInfo.class);
        bean.setAuthenticationStatus(carrierAuditCommand.getAuthStatus());
        bean.setAuthenticationUserId(carrierAuditCommand.getAuthUserId());
        if (!StringUtil.isEmpty(carrierAuditCommand.getRealName())) {
            bean.setName(carrierAuditCommand.getRealName());
        }
        if (!StringUtil.isEmpty(carrierAuditCommand.getIdCardNo())) {
            bean.setIdcardNo(carrierAuditCommand.getIdCardNo());
        }
        if (carrierAuditCommand.getIdCardProvinceCode() != null) {
            bean.setProvinceCode(carrierAuditCommand.getIdCardProvinceCode().toString());
        }
        if (!StringUtil.isEmpty(carrierAuditCommand.getIdCardProvinceName())) {
            bean.setProvinceName(carrierAuditCommand.getIdCardProvinceName());
        }
        if (carrierAuditCommand.getIdCardCityCode() != null) {
            bean.setCityCode(carrierAuditCommand.getIdCardCityCode().toString());
        }
        if (!StringUtil.isEmpty(carrierAuditCommand.getIdCardCityName())) {
            bean.setCityName(carrierAuditCommand.getIdCardCityName());
        }
        if (carrierAuditCommand.getIdCardCountyCode() != null) {
            bean.setAreaCode(carrierAuditCommand.getIdCardCountyCode().toString());
        }
        if (!StringUtil.isEmpty(carrierAuditCommand.getIdCardCountyName())) {
            bean.setAreaName(carrierAuditCommand.getIdCardCountyName());
        }
        if (!StringUtil.isEmpty(carrierAuditCommand.getIdCardAddress())) {
            bean.setAddress(carrierAuditCommand.getIdCardAddress());
        }
        if (!StringUtil.isEmpty(carrierAuditCommand.getIdCardFront())) {
            bean.setIdcardPic(carrierAuditCommand.getIdCardFront());
        }
        if (!StringUtil.isEmpty(carrierAuditCommand.getIdCardBehind())) {
            bean.setIdcardReversePic(carrierAuditCommand.getIdCardBehind());
        }
        if (!StringUtil.isEmpty(carrierAuditCommand.getCooperateEnterpriseName())) {
            bean.setAuxiliaryEnterpriseName(carrierAuditCommand.getCooperateEnterpriseName());
        }
        if (!StringUtil.isEmpty(carrierAuditCommand.getCooperateType())) {
            bean.setAuxiliaryContent(carrierAuditCommand.getCooperateType());
        }
        if (!StringUtil.isEmpty(carrierAuditCommand.getRemark())) {
            bean.setAuthenticationRemark(carrierAuditCommand.getRemark());
        }
        if (carrierAuditCommand.getIdCardStartTime() != null) {
            bean.setIdcardStartTime(carrierAuditCommand.getIdCardStartTime());
        }
        if (carrierAuditCommand.getIdCardEndTime() != null) {
            bean.setIdcardEndTime(carrierAuditCommand.getIdCardEndTime());
        }
        return bean;
    }

    /**
     * 运力审核转换(字段名称不一致)
     * 运输公司
     * @param companyAuditCommand
     * @return
     */
    public static CarrierInfo converterAuditCompanyInfo(CompanyAuditCommand companyAuditCommand) {
        CarrierInfo bean = KcBeanConverter.toBean(companyAuditCommand, CarrierInfo.class);
        bean.setAuthenticationStatus(companyAuditCommand.getAuthStatus());
        bean.setAuthenticationUserId(companyAuditCommand.getAuthUserId());
        if (!StringUtil.isEmpty(companyAuditCommand.getRealName())) {
            bean.setName(companyAuditCommand.getRealName());
        }
        if (!StringUtil.isEmpty(companyAuditCommand.getIdCardNo())) {
            bean.setIdcardNo(companyAuditCommand.getIdCardNo());
        }
        if (companyAuditCommand.getIdCardProvinceCode() != null) {
            bean.setProvinceCode(companyAuditCommand.getIdCardProvinceCode().toString());
        }
        if (!StringUtil.isEmpty(companyAuditCommand.getIdCardProvinceName())) {
            bean.setProvinceName(companyAuditCommand.getIdCardProvinceName());
        }
        if (companyAuditCommand.getIdCardCityCode() != null) {
            bean.setCityCode(companyAuditCommand.getIdCardCityCode().toString());
        }
        if (!StringUtil.isEmpty(companyAuditCommand.getIdCardCityName())) {
            bean.setCityName(companyAuditCommand.getIdCardCityName());
        }
        if (companyAuditCommand.getIdCardCountyCode() != null) {
            bean.setAreaCode(companyAuditCommand.getIdCardCountyCode().toString());
        }
        if (!StringUtil.isEmpty(companyAuditCommand.getIdCardCountyName())) {
            bean.setAreaName(companyAuditCommand.getIdCardCountyName());
        }
        if (!StringUtil.isEmpty(companyAuditCommand.getIdCardAddress())) {
            bean.setAddress(companyAuditCommand.getIdCardAddress());
        }
        if (!StringUtil.isEmpty(companyAuditCommand.getIdCardFront())) {
            bean.setIdcardPic(companyAuditCommand.getIdCardFront());
        }
        if (!StringUtil.isEmpty(companyAuditCommand.getIdCardBehind())) {
            bean.setIdcardReversePic(companyAuditCommand.getIdCardBehind());
        }
        if (!StringUtil.isEmpty(companyAuditCommand.getRemark())) {
            bean.setAuthenticationRemark(companyAuditCommand.getRemark());
        }
        if (companyAuditCommand.getIdCardStartTime() != null) {
            bean.setIdcardStartTime(companyAuditCommand.getIdCardStartTime());
        }
        if (companyAuditCommand.getIdCardEndTime() != null) {
            bean.setIdcardEndTime(companyAuditCommand.getIdCardEndTime());
        }
        return bean;
    }

    /**
     * 驳回原因转换为List
     * {"公司地址":["有误"],"营业执照":["缺失","模糊","缺少授权"],"custom":"asdfa"}
     * @param rejectReason
     * @return
     */
    private static List<String> rejectReasonConverter(Map<Long, String> rejectMap, String rejectReason) {
        if (StringUtil.isEmpty(rejectReason)) {
            return new ArrayList<>();
        }
        List<String> res = new ArrayList<>();
        Map<String, Object> map = JSON.parseObject(rejectReason);
        map.remove("custom");
        Iterator<String> iterator = map.keySet().iterator();
        while(iterator.hasNext()) {
            String key = iterator.next();
            Object objValue = map.get(key);
            if (objValue instanceof JSONArray) {
                JSONArray list = (JSONArray) objValue;
                for (int i = 0; i < list.size(); i++) {
                    Object o = list.get(i);
                    if (o instanceof Integer) {
                        Integer v = (Integer)o;
                        String value = rejectMap.getOrDefault(v.longValue(), "有误");
                        res.add(key + value);
                    }
                }
                continue;
            }
        }
        return res.size() > 0 ? res : new ArrayList<>();
    }

    /**
     * 修改司机信息CarrierInfoCommand转换为CarrierInfo
     * @param carrierInfoCommand
     * @return
     */
    public static CarrierInfo converterCarrierInfoToCarrierInfo(CarrierInfoCommand carrierInfoCommand) {
        CarrierInfo carrierInfo = KcBeanConverter.toBean(carrierInfoCommand, CarrierInfo.class);
        carrierInfo.setId(carrierInfoCommand.getCarrierId());
        carrierInfo.setName(carrierInfoCommand.getRealName());
        carrierInfo.setIdcardNo(carrierInfoCommand.getIdCardNo());
        carrierInfo.setBirthDate(carrierInfoCommand.getBirthday());
        carrierInfo.setIdcardStartTime(carrierInfoCommand.getIdCardStartTime());
        carrierInfo.setIdcardEndTime(carrierInfoCommand.getIdCardEndTime());
        carrierInfo.setProvinceCode(carrierInfoCommand.getIdCardProvinceCode() == null ? null : carrierInfoCommand.getIdCardProvinceCode().toString());
        carrierInfo.setProvinceName(carrierInfoCommand.getIdCardProvinceName());
        carrierInfo.setCityCode(carrierInfoCommand.getIdCardCityCode() == null ? null : carrierInfoCommand.getIdCardCityCode().toString());
        carrierInfo.setCityName(carrierInfoCommand.getIdCardCityName());
        carrierInfo.setAreaCode(carrierInfoCommand.getIdCardCountyCode() == null ? null : carrierInfoCommand.getIdCardCountyCode().toString());
        carrierInfo.setAreaName(carrierInfoCommand.getIdCardCountyName());
        carrierInfo.setAddress(carrierInfoCommand.getIdCardAddress());
        carrierInfo.setIdcardPic(carrierInfoCommand.getIdCardFront());
        carrierInfo.setIdcardReversePic(carrierInfoCommand.getIdCardBehind());
        carrierInfo.setDriverQualificationPic(carrierInfoCommand.getDriverQualificationPic());
        carrierInfo.setDrivingLicencePic(carrierInfoCommand.getDrivingLicencePic());
        carrierInfo.setDrivingLicenceNo(carrierInfoCommand.getDrivingLicenceNo());
        carrierInfo.setDriverLicenseEndTime(carrierInfoCommand.getDriverLicenseEndTime());
        carrierInfo.setAllowDrivingModel(carrierInfoCommand.getAllowDrivingModel());
        carrierInfo.setAuxiliaryEnterpriseName(carrierInfoCommand.getCooperateEnterpriseName());
        carrierInfo.setUnifiedSocialCreditCode(carrierInfoCommand.getCooperateUnifiedSocialCreditCode());
        carrierInfo.setAuxiliaryContent(carrierInfoCommand.getCooperateType());
        carrierInfo.setAuthenticationRemark(carrierInfoCommand.getRemark());
        return carrierInfo;
    }

    /**
     * 修改司机信息CarrierInfoCommand转换为CarrierCooperateInfo
     * @param carrierInfoCommand
     * @return
     */
    public static CarrierCooperateInfo converterCarrierInfoToCarrierCooperate(CarrierInfoCommand carrierInfoCommand) {
        CarrierCooperateInfo carrierCooperateInfo = KcBeanConverter.toBean(carrierInfoCommand, CarrierCooperateInfo.class);
        carrierCooperateInfo.setCarrierId(carrierInfoCommand.getCarrierId());
        carrierCooperateInfo.setEnterpriseName(carrierInfoCommand.getCooperateEnterpriseName());
        carrierCooperateInfo.setUnifiedSocialCreditCode(carrierInfoCommand.getCooperateUnifiedSocialCreditCode());
        carrierCooperateInfo.setCooperateType(carrierInfoCommand.getCooperateType());
        carrierCooperateInfo.setCooperateProvePic(carrierInfoCommand.getCooperateProvePic());
        carrierCooperateInfo.setEnterFlag(carrierInfoCommand.getEnterFlag());
        carrierCooperateInfo.setValidityFlag(carrierInfoCommand.getValidityFlag());
        return carrierCooperateInfo;
    }

    /**
     * 修改司机信息CarrierInfoCommand转换为CarrierCompanyInfo
     * @param carrierInfoCommand
     * @return
     */
    public static CarrierCompanyInfo converterCarrierInfoToCarrierCompany(CarrierInfoCommand carrierInfoCommand) {
        CarrierCompanyInfo carrierCompanyInfo = KcBeanConverter.toBean(carrierInfoCommand, CarrierCompanyInfo.class);
        carrierCompanyInfo.setCarrierId(carrierInfoCommand.getCarrierId());
        carrierCompanyInfo.setBusinessLicencePic(carrierInfoCommand.getBusinessLicencePic());
        carrierCompanyInfo.setBusinessLicenceEndTime(carrierInfoCommand.getBusinessLicenceEndTime());
        carrierCompanyInfo.setRoadPermitPic(carrierInfoCommand.getRoadPermitPic());
        carrierCompanyInfo.setEnterpriseName(carrierInfoCommand.getEnterpriseName());
        carrierCompanyInfo.setLegalName(carrierInfoCommand.getRealName());
        carrierCompanyInfo.setUnifiedSocialCreditCode(carrierInfoCommand.getUnifiedSocialCreditCode());
        carrierCompanyInfo.setAddress(carrierInfoCommand.getAddress());
        return carrierCompanyInfo;
    }

    /**
     * 修改司机信息CarrierInfoCommand转换为CarrierInfo
     * @param carrierInfoCommand
     * @return
     */
    public static CarrierInfo converterCarrierInfoCommand(CarrierInfoCommand carrierInfoCommand) {
        CarrierInfo carrierInfo = KcBeanConverter.toBean(carrierInfoCommand, CarrierInfo.class);
        carrierInfo.setId(carrierInfoCommand.getCarrierId());
        carrierInfo.setName(carrierInfoCommand.getRealName());
        carrierInfo.setIdcardNo(carrierInfoCommand.getIdCardNo());
        carrierInfo.setBirthDate(carrierInfoCommand.getBirthday());
        carrierInfo.setIdcardStartTime(carrierInfoCommand.getIdCardStartTime());
        carrierInfo.setIdcardEndTime(carrierInfoCommand.getIdCardEndTime());
        carrierInfo.setProvinceCode(carrierInfoCommand.getIdCardProvinceCode() == null ? null : carrierInfoCommand.getIdCardProvinceCode().toString());
        carrierInfo.setProvinceName(carrierInfoCommand.getIdCardProvinceName());
        carrierInfo.setCityCode(carrierInfoCommand.getIdCardCityCode() == null ? null : carrierInfoCommand.getIdCardCityCode().toString());
        carrierInfo.setCityName(carrierInfoCommand.getIdCardCityName());
        carrierInfo.setAreaCode(carrierInfoCommand.getIdCardCountyCode() == null ? null : carrierInfoCommand.getIdCardCountyCode().toString());
        carrierInfo.setAreaName(carrierInfoCommand.getIdCardCountyName());
        carrierInfo.setAddress(carrierInfoCommand.getIdCardAddress());
        carrierInfo.setIdcardPic(carrierInfoCommand.getIdCardFront());
        carrierInfo.setIdcardReversePic(carrierInfoCommand.getIdCardBehind());
        carrierInfo.setDriverQualificationPic(carrierInfoCommand.getDriverQualificationPic());
        carrierInfo.setDrivingLicencePic(carrierInfoCommand.getDrivingLicencePic());
        carrierInfo.setDrivingLicenceNo(carrierInfoCommand.getDrivingLicenceNo());
        carrierInfo.setDriverLicenseEndTime(carrierInfoCommand.getDriverLicenseEndTime());
        carrierInfo.setAllowDrivingModel(carrierInfoCommand.getAllowDrivingModel());
        carrierInfo.setAuxiliaryEnterpriseName(carrierInfoCommand.getCooperateEnterpriseName());
        carrierInfo.setUnifiedSocialCreditCode(carrierInfoCommand.getCooperateUnifiedSocialCreditCode());
        carrierInfo.setAuxiliaryContent(carrierInfoCommand.getCooperateType());
        return carrierInfo;
    }

//    /**
//     * 修改司机信息CarrierInfoCommand转换为CarrierInfo
//     * @param carrierInfoCommand
//     * @return
//     */
//    public static CarrierInfo converterCarrierInfoCommand(CarrierInfoCommand carrierInfoCommand) {
//        CarrierInfo carrierInfo = KcBeanConverter.toBean(carrierInfoCommand, CarrierInfo.class);
//        carrierInfo.setId(carrierInfoCommand.getCarrierId());
//        carrierInfo.setName(carrierInfoCommand.getRealName());
//        carrierInfo.setIdcardNo(carrierInfoCommand.getIdCardNo());
//        carrierInfo.setBirthDate(carrierInfoCommand.getBirthday());
//        carrierInfo.setIdcardStartTime(carrierInfoCommand.getIdCardStartTime());
//        carrierInfo.setIdcardEndTime(carrierInfoCommand.getIdCardEndTime());
//        carrierInfo.setProvinceCode(carrierInfoCommand.getIdCardProvinceCode() == null ? null : carrierInfoCommand.getIdCardProvinceCode().toString());
//        carrierInfo.setProvinceName(carrierInfoCommand.getIdCardProvinceName());
//        carrierInfo.setCityCode(carrierInfoCommand.getIdCardCityCode() == null ? null : carrierInfoCommand.getIdCardCityCode().toString());
//        carrierInfo.setCityName(carrierInfoCommand.getIdCardCityName());
//        carrierInfo.setAreaCode(carrierInfoCommand.getIdCardCountyCode() == null ? null : carrierInfoCommand.getIdCardCountyCode().toString());
//        carrierInfo.setAreaName(carrierInfoCommand.getIdCardCountyName());
//        carrierInfo.setAddress(carrierInfoCommand.getIdCardAddress());
//        carrierInfo.setIdcardPic(carrierInfoCommand.getIdCardFront());
//        carrierInfo.setIdcardReversePic(carrierInfoCommand.getIdCardBehind());
//        carrierInfo.setDriverQualificationPic(carrierInfoCommand.getDriverQualificationPic());
//        carrierInfo.setDrivingLicencePic(carrierInfoCommand.getDrivingLicencePic());
//        carrierInfo.setDrivingLicenceNo(carrierInfoCommand.getDrivingLicenceNo());
//        carrierInfo.setDriverLicenseEndTime(carrierInfoCommand.getDriverLicenseEndTime());
//        carrierInfo.setAllowDrivingModel(carrierInfoCommand.getAllowDrivingModel());
//        carrierInfo.setAuxiliaryEnterpriseName(carrierInfoCommand.getCooperateEnterpriseName());
//        carrierInfo.setUnifiedSocialCreditCode(carrierInfoCommand.getCooperateUnifiedSocialCreditCode());
//        carrierInfo.setAuxiliaryContent(carrierInfoCommand.getCooperateType());
//        return carrierInfo;
//    }
}
